<div class="cl pd-5 bg-1 bk-gray mb-10">
  <a onclick="layer_open('添加商品','__MODULE__/Goods/dailiAddEdit')" href="javascript:;" class="btn btn-primary radius l"><i class="Hui-iconfont">&#xe600;</i> 添加商品</a>
  <span class="r mt-3">共有数据：<strong>{$rows}</strong> 条</span>
</div>
<table id="xctable" class="table table-border table-bordered table-hover table-bg table-sort">
  <thead>
    <tr class="text-c">
      <th width="60" id="dg_id" onClick="tab_sort(this)"><div class="">编号</div></th>
      <th width="300" id="dg_name" onClick="tab_sort(this)"><div class="">商品信息</div></th>
      <th width="140" id="dg_money" onClick="tab_sort(this)"><div class="">市场价</div></th>
      <th width="140" id="dg_price" onClick="tab_sort(this)"><div class="">销售价</div></th>
      <th width="80" id="dg_stock" onClick="tab_sort(this)"><div class="">库存</div></th>

      <th width="60">操作</th>
    </tr>
  </thead>
  <tbody>
    <volist name="list" id="vo">
    <tr class="text-c">
      <td>{$i}</td>
      <td class="text-l">
        <dl style="text-align:left">
          <dt><img src="__UPLOAD__/{$vo.dg_thumb|default='img/no_image.jpg'}" width="80" height="80" style="float:left; border-radius: 5%;" /></dt>
          <dd style="padding:0 0 10px 90px; line-height:20px">{$vo.dg_name}</dd>
        </dl>
        <span style="color:#999; font-size:12px;float: left; padding-left: 10px"><p>
          <img src="__PUBLIC__/admin/images/<if condition='$vo[dg_sale] eq 1'>sj1.png<else />sj2.png</if>" onclick="changeTableValGoods('daili_goods','dg_id={$vo.dg_id}','dg_sale','sj',this)"/>
        </p></span>
        </td>
      <td class="text-c">{$vo.dg_money}元</td>
      <td class="text-c">{$vo.dg_price}元</td>
      <td><input type="text" class="input-text text-c" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')" onpaste="this.value=this.value.replace(/[^\d.]/g,'')"  onchange="ajaxUpFieldValue('daili_goods','dg_id={$vo.dg_id}','dg_stock',this);" value="{$vo.dg_stock}" style="border-radius:5px" /></td>

      <td class="td-manage" style="width: 100px">
        <a onclick="layer_open('修改商品','__MODULE__/Goods/dailiAddEdit?id={$vo.dg_id}')" href="javascript:;" class="ml-5" style="text-decoration:none">编辑</a>
        <a style="text-decoration:none" href="javascript:;" onclick="del(this,'{$vo.dg_id}')"title="删除">删除</a>
      </td>
    </tr>
    </volist>
  </tbody>
</table>
{$page}<!-- 分页-->
<script type="text/javascript">
$(".pagination a").click(function(){
	var page = $(this).data('p');
	ajax_get_table('myfrom1',page);
});
/*删除*/
function del(obj, id) {
  layer.confirm('确认要删除吗？', function(index) {
    $.ajax({
      type : 'post',
      url : '__MODULE__/Goods/delIm',
      data : {id:id},
      dataType : 'json',
      success : function(res){
        if(res.status == 1){
          $(obj).parents("tr").remove();
          layer.msg('已删除!', {icon: 1,time: 1000});
        }else{
          layer.msg(res.msg, {icon: 2});
        }
      },
      error : function(XMLHttpRequest, textStatus, errorThrown) {
        layer.alert('网络失败，请刷新页面后重试',{icon:2});
      }
    })
  });
}
</script>